package com.tedu.bill.demo2;

import java.io.Serializable;

/**
 * Author：毕龙
 * Date: 2024/4/14 10:46
 * 不能多继承
 * Class cannot extend multiple classes
 */
public class Student extends Person  {

    @Override
    public void sleep() {
        //super.sleep();
        System.out.println("学生中午要午睡");
    }
    /*
      如果子类的方法和父类的方法名字和参数一致 就构成重写的必要条件
    * 'sleep(int)' in 'com.tedu.bill.demo2.Student'
    * clashes with 'sleep(int)' in 'com.tedu.bill.demo2.Person';
    * attempting to use incompatible return type*/
    public void sleep(int hours){
        System.out.println("学生中午睡"+hours+"小时");
    }

    public String sleep(String hours){
        return hours;
    }
    /*如果子类的方法和父类的方法名字和参数一致 就构成重写的必要条件
    访问修饰符相同 或者更宽
    写成protected 或 public都可以
    * 'eat(String)' in 'com.tedu.bill.demo2.Student' clashes with 'eat(String)' in 'com.tedu.bill.demo2.Person';
    * attempting to assign weaker access privileges ('package-private'); was 'protected'
    * */
    public void eat(String foods){
        System.out.println("学生在吃"+foods);
    }


}
